package logic.SysPerson

import cn.ibizlab.util.domain.EntityBase
import cn.ibizlab.util.helper.RuleUtils
import cn.ibizlab.util.security.AuthenticationUser
import cn.ibizlab.util.security.SpringContextHolder
import cn.ibizlab.core.ad.domain.SysPerson
import cn.ibizlab.core.ad.service.SysPersonService
import cn.ibizlab.core.ad.domain.SysPerson
import cn.ibizlab.core.ad.service.SysPersonService
import cn.ibizlab.core.ad.domain.SysPerson
import cn.ibizlab.core.ad.service.SysPersonService
import cn.ibizlab.core.ad.domain.SysOrganization
import cn.ibizlab.core.ad.service.SysOrganizationService
import com.alibaba.fastjson.JSONObject
import org.springframework.util.ObjectUtils

/**
 *  获取人员清单信息(指定单位/部门/用户组)
 */
class Items {

    //当前用户
    def curuser = AuthenticationUser.getAuthenticationUser()
    //传入变量
    def _default
    //过滤器
    def _fiter1 = new SysPerson()
    //list
    def _list = new SysPerson()
    //organization
    def _organization = new SysOrganization()
    def _orgid = new EntityBase()
    //返回参数
    def _return

    def execute(arg) {
        println 'running....'
        _default = arg
        
        
        
        _return = arg
        begin()
        println 'running end....'
        return _return
    }

    //开始
    def begin() {
    
        //连接名称
        if(true) {
            prepareparam1()
        }
    }

    //实体行为
    def deaction1() {
        SpringContextHolder.getBean(SysOrganizationService.class).findOrganizationId(_organization)

        //orgid not null
        if(((RuleUtils.test(_orgid, 'ISNOTNULL', 'null')))) {
            prepareparam2()
        }
        //orgid null
        else if(((RuleUtils.test(_orgid, 'ISNULL', 'null')))) {
            dedataquery1()
        }
    }

    //准备参数
    def prepareparam1() {
        _fiter1.set("size", "10000")
        _organization.set("id", _default.get("organization_id"))
        _organization.set("dc", _default.get("dc"))
        _fiter1.set("n_employee_number_in", _default.get("employee_number"))
        _fiter1.set("n_id_in", _default.get("id"))
        _fiter1.set("n_uid_in", _default.get("uid"))
        _fiter1.set("n_identification_number_in", _default.get("identification_number"))
        _fiter1.set("n_display_name_like", _default.get("display_name"))
        _fiter1.set("organization_id", _default.get("organization_id"))
        _fiter1.set("department_id", _default.get("department_id"))
        _fiter1.set("organizational_role_id", _default.get("organizational_role_id"))

        //orgid not null
        if(((RuleUtils.test(_default.get('organization_id'), 'ISNOTNULL', 'null')))) {
            deaction1()
        }
        //orgid null
        else if(((RuleUtils.test(_default.get('id'), 'ISNULL', 'null')))) {
            dedataquery1()
        }
    }

    //准备参数
    def prepareparam2() {
        _fiter1.set("organization_id", _orgid.get(""))

        if(true) {
            dedataquery1()
        }
    }

    //查询人员External
    def dedataquery1() {
        //DEDataQuery 暂未实现
        if(true) {
            end1()
        }
    }

    //结束
    def end1() {
        _return = _list

    }

}
